class bannerModel{
  constructor(){
    this.db = require('../../config/db')
  }

   //获取所有轮播图信息
   banner(){
    let sql = 'select * from banner'
    return this.db.query(sql)
  }
  //分页搜索轮播图
  searchBanner(pagenum,pagesize){
    let sql = 'select * from banner order by pubdate DESC limit ?,?'
    return this.db.query(sql,[pagenum,pagesize])
  }
  //查询轮播图id
  queryBannerID(id){
    let sql = 'select * from banner where id = ?'
    console.log(sql)
    return this.db.query(sql,[id])
  }
  //修改轮播图
  updateBanner(title,img,EnglishName,describes,btnName,href,id){
    let sql = "update banner set title = ?,img = ?,EnglishName = ?,describes = ?,btnName = ?,href = ? where id = ?"
    return this.db.query(sql,[title,img,EnglishName,describes,btnName,href,id])
  }
  //新增轮播图
  addBanner(title,img,EnglishName,describes,btnName,href){
    let sql = "insert into banner (title,img,EnglishName,describes,btnName,href) values (?,?,?,?,?,?)"
    return this.db.query(sql,[title,img,EnglishName,describes,btnName,href])
  }
  //删除轮播图
  deleteBanner(id){
    let sql = 'delete from banner where id = ?'
    return this.db.query(sql,[id])
  }
}
module.exports = new bannerModel()